﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Framework;
using Com.Framework.Enc;
using Com.Library.DB.User;
using Com.Web.coffinegurunaru.AppLogic.Page;

namespace Com.Web.coffinegurunaru.member
{
	public partial class join_02_1 : WebPage
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (this.IsPostBack)
			{
				byte n1GroupType = Request.Form["n1GroupType"].Parse((byte)2);

				if (n1GroupType == 2)
				{
					Response.Redirect("/member/join_02.aspx?se=" + Server.UrlEncode(Crypt.DESEncrypt(DateTime.Now.ToString())));
				}


				UserCreateArguments arg = new UserCreateArguments();
				arg.n1GroupType = Request.Form["n1GroupType"].Parse((byte)2);
				arg.n1UserLevel = 9;
				arg.IsLocalUser = "Y";
				arg.strUserID = Request.Form["strUserID"].Parse(string.Empty);
				arg.strMD5PWD = Crypt.MD5HashCrypt(Request.Form["strUserPWD1"].Parse(string.Empty));
				arg.strUserName = Request.Form["strUserName"].Parse(string.Empty);
				arg.n1Question = Request.Form["n1Question"].Parse((byte)0);
				arg.strAnswer = Request.Form["strAnswer"].Parse(string.Empty);
				UserModel.Create(arg);
				Response.Redirect("/member/join_03.aspx?name=" + Server.UrlEncode(Request.Form["strUserName"].Parse(string.Empty)) + "&se=" + Server.UrlEncode(Crypt.DESEncrypt(DateTime.Now.ToString())));
			}
			else
			{
				try
				{
					string enc = Crypt.DESDecrypt(Request.QueryString["se"].Parse(string.Empty));
					DateTime dt = Convert.ToDateTime(enc);
					if (dt.AddMinutes(10) < DateTime.Now)
					{
						Response.Redirect("/member/join_01.aspx");
					}
				}
				catch
				{
					Response.Redirect("/member/join_01.aspx");
				}
			}
		}
	}
}
